/*
 * fix_length_packet.c
 *
 *  Created on: Aug 22, 2024
 *      Author: 31652
 */

#include "fix_length_packet.h"

uint8_t* __fix_len_buff;

void FixLen_Packet_Init(uint8_t* buff, uint32_t packetLen) {
	__fix_length_packet_len = packetLen;
	__fix_len_buff = buff;
}

void FixLen_Packet_Handle(i_ringbuffer* handle) {
	int i;
	for (;;) {
		if (handle->size < __fix_length_packet_len) {
			break;
		}

		printf("------------------------------------------\n");
		printf("handle packet...\n");
		I_Ring_Buffer_ReadBytes(handle, __fix_len_buff, __fix_length_packet_len);
		printf("packet(string):\n");
		for (i=0; i<__fix_length_packet_len; i++) {
			printf("%c", __fix_len_buff[i]);
		}
		printf("\n");
		printf("after handle packet:\n");
		I_Ring_Status(handle);

		printf("------------------------------------------\n");
		printf(" \n");
	}
}
